<template>
    <div>
      <h3>登录</h3>
      <button @click="login">登录</button>
    </div>
</template>

<script>
export default {
    data() {
        return {

        };
    },
    created() {

    },
    mounted() {

    },
    methods: {
      login(){
          this.$axios({
              url:'/login',
              method:'post',
              data:{
                  username:'alex',
                  password:'axios'
              }
          }).then(res =>{
              //同步vuex cokie
              this.$cookies.set('user',res)
              this.$store.commit('user/M_UPDATE_USER',res)

              if(this.$route.query.path || /login|reg/.test(this.$route.query.path)){
                  this.$router.replace('/user')
              }else{
                //   this.$router.replace(this.$route.query.path)
                  this.$router.replace('/user')
              }
          })
      }
    }
};
</script>

<style scoped lang="scss">

</style>
